package jgo.plugins.jdbc;

import jgo.JGo;
import jgo.Plugin;
import org.springframework.jdbc.core.JdbcTemplate;

public class JdbcTemplatePlugin extends Plugin {
    public static final JdbcTemplatePlugin instance = new JdbcTemplatePlugin();
    public JdbcTemplate jdbcTemplate;

    private JdbcTemplatePlugin() {}

    @Override
    public void init(JGo gin) {
    	
        MySqlPlugin mySqlPlugin =gin.getPlugin(MySqlPlugin.class);
        if (mySqlPlugin == null) {
            throw new RuntimeException("MySqlPlugin not found. Please add MySqlPlugin before JdbcTemplatePlugin.");
        }
        jdbcTemplate = new JdbcTemplate(mySqlPlugin.dataSource);
    }

}